<?php 
include('../conn.php');
//再来一单

if(!isset($_GET['ordersid']) || !is_numeric($_GET['ordersid'])){
	echo json_encode(array('code'=>-100,'msg'=>'信息异常'));
	exit;
}

$ordersid = $_GET['ordersid'];

$car_sql_query = mysql_query("select userid,cityid,goodsid,goodsname,fTitle,sTitle,price,number,shopid from car where ordersid = $ordersid");

$car_ids = array();
mysql_query("BEGIN");
while ($car_row = mysql_fetch_assoc($car_sql_query)) {
	$userid = $car_row['userid'];
	$cityid = $car_row['cityid'];
	$goodsid = $car_row['goodsid'];
	$goodsname = $car_row['goodsname'];
	$fTitle = $car_row['fTitle'];
	$sTitle = $car_row['sTitle'];
	$price = $car_row['price'];
	$number = $car_row['number'];
	$shopid = $car_row['shopid'];
	$state = 0;
	$created_at = date("Y-m-d H:i:s");
	mysql_query("insert into car(userid,cityid,goodsid,goodsname,fTitle,sTitle,price,number,shopid,state,created_at) values($userid,'$cityid',$goodsid,'$goodsname','$fTitle','$sTitle','$price',$number,$shopid,$state,'$created_at')");
	
	$id = mysql_insert_id();
	if(!$id){
		mysql_query("ROLLBACK"); 
		mysql_query("END");
		echo json_encode(array('code'=>-100,'msg'=>'信息异常1'));
		exit;
	}
	$car_ids[$goodsid.""] = $id;
}
mysql_query("COMMIT"); 
mysql_query("END");

echo json_encode(array('code'=>200,'msg'=>'成功','data'=>$car_ids));















 ?>